{include file="admin/top.php" subject='products'}
{include file="products/top.php" subject='products'}
<div id="content">
  <form method="post">
  {products limit=1 id=$segment.id}
    <table width="100%" border="0" cellpadding="5" cellspacing="0" id="editor">
        {if 0}<tr>
        <td class="title">产品供应商:<br/><br/><select onchange="$('[shopid]').hide();$('[shopid='+this.value+']').show();">{shops}<option value="{$shops.id}" {if $shops.id==$products.shopid}selected{/if} {if 1==$shops.disabled}disabled{/if}>{$shops.title}</option>{/shops}</select></td>
        <td class="content">
<!--         <select name="classid"> -->
<!--         <option value="0">未指定</option> -->
<!--         {foreach from=$myclasses key=key item=item} -->
<!--         <option value="{$item.id}" priceline="{$item.priceline}" priceunderline="{$item.priceunderline}" {if $item.id==$products.classid}selected{/if}> -->
<!--         {$item.title} -->
<!--         </option> -->
<!--         {if $item.children} -->
<!--         {foreach from=$item.children key=sub_key item=sub_item} -->
<!--          <option value="{$sub_item.id}" priceline="{$sub_item.priceline}" priceunderline="{$sub_item.priceunderline}" {if $sub_item.id==$products.classid}selected{/if}> -->
<!--         |——{$sub_item.title} -->
<!--         </option> -->
<!--         {/foreach} -->
<!--         {/if} -->
<!--         {/foreach} -->
        
<!--         </select> * -->
        
        	<select name="supplier[]" multiple="multiple" size="10" style="height: auto;">
        		{foreach from=$suppliers item=item}
        			<option value="{$item.id}" {if @in_array($item.id,explode(",",$products.supplieid))}selected{/if} shopid="{$item.shopid}" style="{if $products.shopid!=$item.shopid}display:none;{else}{/if}">{$item.title}</option>
        		{/foreach}
        	</select>按住ctrl多选
        </td>
        <td class="content"> {if $errors.empty_supplier}<span class="warning">请指定供应商</span>
        {else}指定供应商
        {/if}</td>
      </tr>{/if}
      <tr>
        <td width="100" class="title">产品名称:</td>
        <td width="240" class="content"><input name="title" type="text" id="title" value="{$smarty.post.title|default:$products.pname:1}" size="30" readonly="true"/> *</td>
        <td width="821" class="content">
<!--         {if $errors.empty_title}<span class="warning">产品名称不能为空</span> -->
<!--         {else} 
        {/if}        -->填写产品的名称</td>
      </tr>
      <tr>
        <td class="title">产品规格:</td>
        <td class="content"><input name="spec" type="text" id="spec" value="{$smarty.post.spec|default:$products.spec:1}" size="30"  disabled="true"/></td>
        <td class="content">填写产品规格, 如 50g，200ml等</td>
      </tr>
      {if 0}<tr>
        <td class="title">采购单价:</td>
        <td class="content">
        	<input name="pricebuy" type="text" id="pricebuy" value="{$smarty.post.pricebuy|default:$products.pricebuy}" size="30" update_price=1/>
        	<select name="currency_unit">
        		<option value="">---请选择---</option>
        		{foreach from=$currency_unit_arr item=culist}
        		<option value="{$culist.unit_en}" {if $products.currency_unit==$culist.unit_en}selected{/if}>{$culist.unit_name}</option>
        		{/foreach}
        	</select>
        	 *
        </td>
        <td class="content">{if $errors.empty_pricebuy}<span class="warning">采购单价不能为空</span>
        {else}填写采购单价<span class="warning">(请选择正确的货币单位)</span>
        {/if} </td>
      </tr>{/if}
<!--       <tr> -->
<!--         <td class="title">销售底价:</td> -->
<!--         <td class="content" style="width:580px;"><input name="priceundersell" type="text" id="priceundersell" value="{$smarty.post.priceundersell|default:$products.priceundersell}" size="30" update_price=1/>=采购单价×(1+销售底价底利率<input type="text" id="priceunderline" value="{if $products.priceundersell==''}0.00{else}{math equation='x/y' x=$products.priceundersell y=$products.pricebuy format='%.2f'}{/if}" size="10" update_price=1>(%))</td> -->
<!--         <td class="content">{if $errors.empty_priceundersell}<span class="warning">销售底价不能为空</span> -->
<!--         {else}填写销售底价 -->
<!--         {/if} </td> -->
<!--       </tr> -->
<!--       <tr> -->
<!--         <td class="title">销售单价:</td> -->
<!--         <td class="content"><input name="pricesell" type="text" id="pricesell" value="{$smarty.post.pricesell|default:$products.pricesell}" size="30" update_price=1/>=采购单价×&nbsp;&nbsp;&nbsp;(1+销售价底利率<input type="text" id="priceline" value="{if $products.pricesell==''}0.00{else}{math equation='x/y' x=$products.pricesell y=$products.pricebuy format='%.2f'}{/if}" size="10" update_price=1>(%))</td> -->
<!--         <td class="content">{if $errors.empty_pricesell}<span class="warning">销售单价不能为空</span> -->
<!--         {else}填写销售单价 -->
<!--         {/if} </td> -->
<!--       </tr> -->
      <tr>
        <td class="title">库存单位:</td>
        <td class="content"><input name="unit" type="text" id="unit" value="{$smarty.post.unit|default:$products.unit}" size="30" /></td>
        <td class="content">{if $errors.empty_unit}<span class="warning">库存单位不能为空</span>{else}库存计算的单位, 如: 个, 箱, 件, 斤等{/if}</td>
      </tr>
<!--       <tr> -->
<!--         <td class="title">最小出库单位:</td> -->
<!--         <td class="content" style="width:580px;"><input  type="text" name="minnum" value="{$smarty.post.minnum|default:$products.minnum}" size="30" /></td> -->
<!--         <td class="content">设置此值后将以此最小单位出库</td> -->
<!--       </tr> -->
<!--       <tr> -->
<!--         <td class="title">最大出库单位:</td> -->
<!--         <td class="content" style="width:580px;"><input  type="text" name="maxnum" value="{$smarty.post.maxnum|default:$products.maxnum}" size="30" /></td> -->
<!--         <td class="content">设置此值后将以此最大单位出库</td> -->
<!--       </tr> -->
      <tr>
        <td class="title">预警数量:</td>
        <td class="content" style="width:580px;"><input  type="text" name="shopwarningnum" value="{$smarty.post.shopwarningnum|default:$products.shopwarningnum}" size="30" /></td>
        <td class="content">该商品的预警数量（默认为 5），如果此商品没有具体的预警数量，则继承父类的预警数量值</td>
      </tr>
      
     
       <tr>
        <td class="title">预售数量:</td>
        <td class="content"><input name="wanttobuy" type="text" id="wanttobuy" value="{$smarty.post.wanttobuy|default:$products.wanttobuy}" size="30" /> <input type="checkbox" onclick="setYS(this)" id="setysCheckBox">只销售实际库存</td>
        <td class="content">预售数量，可以初始化虚拟库存</td>
      </tr>
      
        <tr>
        <td class="title">虚拟库存:</td>
        <td class="content"><input name="canbuyout" type="text" id="canbuyout" value="{$smarty.post.canbuyout|default:$products.canbuyout}" size="30" readonly style="background:#eee;border:1px solid #aaa;"/> <a href="javascript:void(0);" onclick="if(confirm('初始化虚拟库存会影响销售库存情况，确认初始化？'))$('#canbuyout').val($('#wanttobuy').val())">初始化虚拟库存</a></td>
        <td class="content">允许虚拟销售的库存数，如果为负值则此商品为0不显示缺货，库存为负此值或以下时，显示缺货</td>
      </tr>
      <tr>
        <td class="title">实际库存:</td>
        <td class="content"><input name="stocks" type="text" id="stocks" value="{$smarty.post.stocks|default:$products.stocks}" readonly size="30" style="background:#eee;border:1px solid #aaa;{if $products.stocks>0}color:red;{/if}"/></td>
        <td class="content">实际库存数量</td>
      </tr>
<!--       <tr class="noline"> -->
<!--         <td class="title">产品介绍:</td> -->
<!--         <td colspan="2" class="content"><textarea name="intro" cols="100" rows="8" id="intro">{$smarty.post.intro|default:$products.intro}</textarea></td> -->
<!--       </tr> -->
      <tr>
        <td class="title">是否应用到商品:</td>
        <td class="content"><input name="is_apply_all" type="checkbox" id="is_apply_all" value="1"/> </td>
        <td class="content" style="color: red;">如果勾选，则整个商品（即该SKU所属商品下的所有SKU）都应用以上设置</td>
      </tr>
      <tr class="noline">
      	<td class="title">产品条码数字:</td>
      	<td class="content"><input name="barcode" type="text" id="barcode" value="{$smarty.post.barcode|default:$products.barcode}" onkeyup="this.value=this.value.replace(/\D/g,'')"  onafterpaste="this.value=this.value.replace(/\D/g,'')" maxlength="13" size="30"/></td>
        <td class="content">
         {if $errors.barcode_num}<span class="warning">条码数字必须为13位数字哟</span>
         {else}填写产品条码数字, 如 4711161741799等
		{/if}
		</td>
      </tr>
    </table>
    
    <div class="fr mt10">
    <input type="submit" value="确定" class="btn" />
    <a href="javascript:window.history.go(-1);" class="btn">取消</a> 
    <input name="id" type="hidden" id="id" value="{$products.id}" />
    <input name="referer" type="hidden" id="referer" value="{$smarty.post.referer|default:$smarty.server.HTTP_REFERER:1}" />
    <input name="action" type="hidden" id="action" value="modify" />
    </div>
	{/products}
	
  </form>
</div>
<script type="text/javascript">
//<!--{literal}

if($('#wanttobuy').val()==0){
	$('#wanttobuy').attr('readonly','readonly').css({background:'#eee',border:'1px solid #aaa'});
	$('#setysCheckBox').attr('checked','checked');
}


function setYS(o){
	var $$=$(o);
	if($$.is(':checked')){
		if(confirm('只销售库存会清除虚拟库存和预售数量，确认？')){
			$('#wanttobuy').val('0').attr('readonly','readonly').css({background:'#eee',border:'1px solid #aaa'});$('#canbuyout').val('0');
		}

	}else{

		$('#wanttobuy').removeAttr('readonly').css({background:'',border:''});


		}


	}


//{/literal}-->
</script>
{include file="admin/bottom.php"}
</body>
</html>
